package com.sleep.psy.external_server.business.main.controller;


import com.sleep.psy.external_server.business.main.entity.MainScheme;
import com.sleep.psy.external_server.business.main.service.MainSchemeService;
import com.sleep.psy.external_server.result.Result;
import com.sleep.psy.external_server.result.ResultEnum;
import com.sleep.psy.external_server.result.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 方案表 前端控制器
 * </p>
 *
 * @author wenliguo
 * @since 2025-08-13
 */
@Api(tags = "方案")
@RestController
@RequestMapping("/mainScheme")
public class MainSchemeController {

    protected Logger logger = LoggerFactory.getLogger(MainSchemeController.class);

    @Autowired
    private MainSchemeService mainSchemeService;

    /**
     * 通过方案id获取有效方案
     * @author wenliguo
     * @date 2025/8/17 10:30
     * @param schemeId 方案id
     * @return com.sleep.psy.external_server.result.Result<com.sleep.psy.external_server.main.entity.MainScheme>
    */
    @GetMapping("/selectInfoById")
    @ApiOperation(value = "通过方案id获取有效方案")
    public Result<MainScheme> selectInfoById(@RequestParam(value = "schemeId") Integer schemeId) {
        try {
            return mainSchemeService.selectSchemeById(schemeId);
        } catch (Exception e) {
            logger.error("通过方案id获取有效方案出错", e);
            return ResultUtil.error(ResultEnum.SERVER_INTERNAL_ERROR);
        }
    }
}

